
// Common.js 正确的配置格式
module.exports = {
    sourceDir: process.env.WORKSPACE+"/MiniTemplate" || 'process.env.SOURCE_DIR 请配置',    // 根目录
    serverUrl: process.env.SERVER_URL ? process.env.SERVER_URL + "/" : 'http://127.0.0.1:3001/',  // 服务器接收接口
    appid:process.env.APPID || 'testAppid',
    appkey: process.env.APPKEY || 'testkey',
    logTag: '[FolderUploader]',      // 日志标签,
    commonPost: async (serverUrl, uploadData, additionalHeaders = {}) => {
        // Merge default headers with additional headers
        const headers = {
            'Content-Type': 'application/json',
            ...additionalHeaders
        };

        // Send upload request
        const response = await fetch(serverUrl, {
            method: 'POST',
            headers: headers,
            body: JSON.stringify(uploadData)
        });

        console.log("response:" + response);
        const result = await response.json();

        // Handle response
        return {
            success: response.ok,
            status: response.status,
            message: result.msg || (response.ok ? 'Upload successful' : 'Upload failed')
        };
    }
};